<template>
	<view class="item">
		<view class="left">
			<image class="icon" src="https://snpl.scgjcx.com/static/dj.png" mode="aspectFit"></image>
		</view>
		<view class="right">
			<view class="name">{{ device.name }}</view>
			<view class="addr">{{ device.workingStatus ? '运行中' : '已关机' }}</view>
		</view>
		<view class="action">
			<button plain @tap="onClickItem">
				<image class="gj-icon" src="https://snpl.scgjcx.com/static/gj.png"></image>
				<text>{{ device.workingStatus ? '关机' : '开机' }}</text>
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		name:"item",
		props: {
			device: {
				type: Object,
				default: function () {
					return {};
				}
			}
		},
		data() {
			return {
				
			};
		},
		mounted() {
			console.log('item', this.device);
		},
		methods: {
			onClickItem() {
				this.$emit('toggle', this.device);
			}
		}
	}
</script>

<style lang="less" scoped>
	.item {
		background-color: #fff;
		border-radius: 5px;
		box-sizing: border-box;
		padding: 15px 25px;
		margin-bottom: 10px;
		display: flex;
		justify-content: space-between;
		box-shadow: 0 0 2px 2px rgba(153,153, 153, 0.2);
		position: relative;
		
		.left {
			width: 30px;
			.icon {
				width: 100%;
				height: 60px;
			}
		}
		
		.right {
			flex: 1;
			box-sizing: border-box;
			padding-left: 15px;
			
			.name {
				margin-bottom: 15px;
				color: rgb(130, 129, 134);
				font-size: 16px;
			}
			
			.addr {
				//color: rgb(176, 176, 176);
				color: #EEB61B;
				font-size: 12px;
			}
		}

		.action {
			position: absolute;
			bottom: 10px;
			right: 20px;
			button {
				display: flex;
				align-items: center;
				border-radius: 20px;
				border-color: rgb(215, 203, 203);
			}
			.gj-icon {
				width: 20px;
				height: 20px;
				display: block;
			}
			text {
				font-size: 14px;
				display: inline-block;
				color: rgb(93, 93, 93);
			}
			
		}

	}
</style>